Warn if a UTF8_STRING or text/plain;charset=utf-8 roperty contains invalid
authorMatthias Clasen <maclas@gmx.de>
Fri, 17 Sep 2004 03:23:32 +0000 (03:23 +0000)
committerMatthias Clasen <matthiasc@src.gnome.org>
Fri, 17 Sep 2004 03:23:32 +0000 (03:23 +0000)
Thu Sep 16 23:20:05 2004  Matthias Clasen  <maclas@gmx.de>

* gtk/gtkselection.c (selection_get_text_plain):
* gdk/x11/gdkselection-x11.c (make_list): Warn if a UTF8_STRING
or text/plain;charset=utf-8 roperty contains invalid
UTF-8.  (#152845, Owen Taylor)

ChangeLog
ChangeLog.pre-2-10
ChangeLog.pre-2-6
ChangeLog.pre-2-8
gdk/x11/gdkselection-x11.c
gtk/gtkselection.c

index 18175473e527051e166c0138ed237e05a6bcd702..fbb87839fcf021910e789abcc08c576471e43a3b 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,10 @@
+Thu Sep 16 23:20:05 2004  Matthias Clasen  <maclas@gmx.de>
+
+       * gtk/gtkselection.c (selection_get_text_plain): 
+       * gdk/x11/gdkselection-x11.c (make_list): Warn if a UTF8_STRING
+       or text/plain;charset=utf-8 roperty contains invalid 
+       UTF-8.  (#152845, Owen Taylor)
+
 2004-09-16  Matthias Clasen  <mclasen@redhat.com>
 
        Fix #152760, Christian Persch:
index 18175473e527051e166c0138ed237e05a6bcd702..fbb87839fcf021910e789abcc08c576471e43a3b 100644 (file)
@@ -1,3 +1,10 @@
+Thu Sep 16 23:20:05 2004  Matthias Clasen  <maclas@gmx.de>
+
+       * gtk/gtkselection.c (selection_get_text_plain): 
+       * gdk/x11/gdkselection-x11.c (make_list): Warn if a UTF8_STRING
+       or text/plain;charset=utf-8 roperty contains invalid 
+       UTF-8.  (#152845, Owen Taylor)
+
 2004-09-16  Matthias Clasen  <mclasen@redhat.com>
 
        Fix #152760, Christian Persch:
index 18175473e527051e166c0138ed237e05a6bcd702..fbb87839fcf021910e789abcc08c576471e43a3b 100644 (file)
@@ -1,3 +1,10 @@
+Thu Sep 16 23:20:05 2004  Matthias Clasen  <maclas@gmx.de>
+
+       * gtk/gtkselection.c (selection_get_text_plain): 
+       * gdk/x11/gdkselection-x11.c (make_list): Warn if a UTF8_STRING
+       or text/plain;charset=utf-8 roperty contains invalid 
+       UTF-8.  (#152845, Owen Taylor)
+
 2004-09-16  Matthias Clasen  <mclasen@redhat.com>
 
        Fix #152760, Christian Persch:
index 18175473e527051e166c0138ed237e05a6bcd702..fbb87839fcf021910e789abcc08c576471e43a3b 100644 (file)
@@ -1,3 +1,10 @@
+Thu Sep 16 23:20:05 2004  Matthias Clasen  <maclas@gmx.de>
+
+       * gtk/gtkselection.c (selection_get_text_plain): 
+       * gdk/x11/gdkselection-x11.c (make_list): Warn if a UTF8_STRING
+       or text/plain;charset=utf-8 roperty contains invalid 
+       UTF-8.  (#152845, Owen Taylor)
+
 2004-09-16  Matthias Clasen  <mclasen@redhat.com>
 
        Fix #152760, Christian Persch:
index ef079dee22f9e9f5b94c074d98be7a6ee58b6fd5..13aca15ceaa2f69fdc3f3f7c5ecd5a7aa96cb8d0 100644 (file)
@@ -516,7 +516,15 @@ make_list (const gchar  *text,
            }
        }
       else
-       str = g_strndup (p, q - p);
+       {
+         str = g_strndup (p, q - p);
+         if (!g_utf8_validate (str, -1, NULL))
+           {
+             g_warning ("Error converting selection from UTF8_STRING");
+             g_free (str);
+             str = NULL;
+           }
+       }
 
       if (str)
        {
index d0ec8b8bc863646089dd46d8b4e74a33181414c7..e9fab860148797b43e603b0d1bd7c1a7a3cea8db 100644 (file)
@@ -1032,20 +1032,25 @@ selection_get_text_plain (GtkSelectionData *selection_data)
                                     charset, "UTF-8", 
                                     NULL, NULL, &len, &error);
       g_free (tmp);
-    }
 
-  if (!str)
+      if (!str)
+       {
+         g_warning ("Error converting from %s to UTF-8: %s",
+                     charset, error->message);
+         g_error_free (error);
+
+         return NULL;
+       }
+    }
+  else if (!g_utf8_validate (str, -1, NULL))
     {
-      g_warning ("Error converting from %s to UTF-8: %s",
-                charset, error->message);
-      g_error_free (error);
-      
+      g_warning ("Error converting from text/plain;charset=utf-8 to UTF-8");
+      g_free (str);
+
       return NULL;
     }
 
-
   result = normalize_to_lf (str, len);
-
   g_free (str);
 
   return result;